package com.example.a2032.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.a2032.db.DataDbHelper;
import com.example.a2032.db.dao.SleepDataDao;
import com.example.a2032.livedatas.SingleSourceLiveData;
import com.example.a2032.entity.SleepData;

import java.util.List;

public class SleepDataViewModel extends AndroidViewModel {

    private final SingleSourceLiveData<List<SleepData>> realTimeStepObservable;
    SleepDataDao sleepDataDao;

    public SleepDataViewModel(@NonNull Application application) {
        super(application);
        sleepDataDao = DataDbHelper.getInstance(application).getSleepDataDao();
        realTimeStepObservable = new SingleSourceLiveData<>();
    }

    public LiveData<List<SleepData>> getSleepData(String startDate,String endDate){
        realTimeStepObservable.setSource(sleepDataDao.loadSleepData(startDate,endDate));
        return  realTimeStepObservable;
    }
}
